<?php

class AdminModel extends Model {

	public $table = 'admin';

	public function userLogin($data){
		if(empty($data['admin'])){
			$this->error = '用户名不能为空';
			return false;
		}
		if(empty($data['pass'])){
			$this->error = '密码不能为空';
			return false;
		}
		$userInfo = $this->where("username = '{$data['admin']}'")->find();
		if(empty($userInfo)){
			$this->error = '管理员不存在';
			return false;
		}
		if(md5($data['pass']) != $userInfo['password']){
			$this->error = '密码错误';
			return false;
		}
		$_SESSION['aid'] = $userInfo['aid'];
		$_SESSION['admin'] = $userInfo['username'];
		return true;
	}
}


?>